import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询计量单位列表
export function listUnit(data) {
  return request({
    url: '/market/unit/unitList',
    method: 'post',
    data: data
  })
}

// 查询计量单位详细
export function getUnit(unitId) {
  return request({
    url: '/market/unit/' + parseStrEmpty(unitId),
    method: 'get'
  })
}

// 新增计量单位
export function addUnit(data) {
  return request({
    url: '/market/unit',
    method: 'post',
    data: data
  })
}

// 修改计量单位
export function updateUnit(data) {
  return request({
    url: '/market/unit',
    method: 'put',
    data: data
  })
}

// 删除计量单位
export function delUnit(unitId) {
  return request({
    url: '/market/unit/' + unitId,
    method: 'delete'
  })
}

// 计量单位状态修改
export function changeUnitStatus(unitId, status) {
  const data = {
    unitId,
    status
  }
  return request({
    url: '/market/unit/unitChangeStatus',
    method: 'put',
    data: data
  })
}
